package com.rgs.se.sort;




public class _1Quick1 {
    /*快速排序一遍单侧*/
    public void Quick1(int[] arr,int p,int r){
        if(p<r){
            int q = partition(arr,p,r);
            Quick1(arr,p,q-1);
            Quick1(arr,q+1,r);
        }
    }
    /*分区 返回中间固定的位置*/
    public int partition(int[] arr,int p,int r){
        int pivot = arr[p];
        int sp = p+1; //扫描指针
        int bigger = r; //末尾指针
        while(sp <= bigger){
            if(arr[sp] <= pivot){
                sp++;
            }
            else{
                SortUtil.Temp(arr,sp,bigger);
                bigger--;
            }
        }
        SortUtil.Temp(arr,p,bigger);
        return bigger;
    }
}
